package ar.edu.unicen.pladema.ui.menu;

import ar.edu.unicen.pladema.resources.ResourceManager;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;

public class LMenu {
	private Menu mainMenu = null;
	private MenuItem p1MenuItem = null;
	private MenuItem p2MenuItem = null;
	private MenuItem p3MenuItem = null;
	private Menu p1Menu = null;
	private Menu p2Menu = null;
	private Menu p3Menu = null;
	
	public LMenu(Shell shell) {
		mainMenu = new Menu(shell, SWT.BAR);
		
		p1MenuItem = new MenuItem(mainMenu, SWT.CASCADE);
		p2MenuItem = new MenuItem(mainMenu, SWT.CASCADE);
		p3MenuItem = new MenuItem(mainMenu, SWT.CASCADE);
		p1MenuItem.setText(ResourceManager.getInstance().getText("MIP1"));
		p2MenuItem.setText(ResourceManager.getInstance().getText("MIP2"));
		p3MenuItem.setText(ResourceManager.getInstance().getText("MIP3"));
		
		p1Menu = new Menu(shell, SWT.DROP_DOWN);
		p2Menu = new Menu(shell, SWT.DROP_DOWN);
		p3Menu = new Menu(shell, SWT.DROP_DOWN);
		
		p1MenuItem.setMenu(p1Menu);
		p2MenuItem.setMenu(p2Menu);
		p3MenuItem.setMenu(p3Menu);
	    
		shell.setMenuBar(mainMenu);
	}
	
	public void addP1Option(String label, int acelerator, GoToMenuListener listener) {
		MenuItem newGotoOption = new MenuItem(p1Menu, SWT.PUSH);
		newGotoOption.setText(ResourceManager.getInstance().getText(label));
		newGotoOption.setAccelerator(acelerator);
		newGotoOption.addSelectionListener(listener);
	}
	public void addP2Option(String label, int acelerator, GoToMenuListener listener) {
		MenuItem newGotoOption = new MenuItem(p2Menu, SWT.PUSH);
		newGotoOption.setText(ResourceManager.getInstance().getText(label));
		newGotoOption.setAccelerator(acelerator);
		newGotoOption.addSelectionListener(listener);
	}
	public void addP3Option(String label, int acelerator, GoToMenuListener listener) {
		MenuItem newGotoOption = new MenuItem(p3Menu, SWT.PUSH);
		newGotoOption.setText(ResourceManager.getInstance().getText(label));
		newGotoOption.setAccelerator(acelerator);
		newGotoOption.addSelectionListener(listener);
	}
}
